<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page language="java" import="java.util.*" pageEncoding="utf8"%>
<%@ page contentType="text/html;charset=utf8" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Admin Template </title>
<%@ include file="include.jsp"%>

<script type="text/javascript">
$(document).ready(function(){
	
	
	Administry.setup();
	
	/* datatable */
	$('#example').dataTable();
	
	$('#cm').click(function(){
		
		if($('#rss_address').val() == ""){
			alert('please input address');
		}
		else{
			$("#example tbody").html("");
			var rssUrl = $('#rss_address').val();
  			var url = "http://localhost:8080/adminpanel/getRssinfo?ra=";
  			var fullRequest = url+rssUrl;
  			//alert(fullRequest);
  			jQuery.ajax({
  				url: fullRequest,
			  	dataType: "xml",
			  	//type:"post",
			  	contentType: "application/x-www-form-urlencoded; charset=UTF-8",
			  	cache:false,
			    beforeSend:loading,
			    success:Response
			});
		}
		
	});
	
	
	$("#add").click(function() {
  		var str=[];

        $("input[name='checkbox']").each(function() {

	        if($(this).attr("checked")){
				
		        str.push($(this).val());
		        alert(str)
			}

        });
    
     });
	
});

		function loading(){
			$('#loading_img').html('<img src="/adminpanel/img/nyro/ajaxLoader.gif"/>');
		}
		function Response(data){
			$('#loading_img').html("");
			$(data).find('channel').find('item').each(function(index, ele){
				//alert(index);
				var aindex = index+1;
            	var titles = $(ele).find('title').text();
	            var links = $(ele).find('author').text();
	           	var createTime = $(ele).find('pubDate').text();
	            $("#example").find('tbody').append('<tr><td>'+aindex+'</td><td>'+titles+'</td><td>'+links+'</td><td>'+createTime+'</td><td><input type="checkbox" name="checkbox" value='+aindex+' /></td></tr>');
	            
	        })
			
		} 
</script>

</head>
<body>


	<%@ include file="header.jsp"%>
	<!-- Page content -->
	<div id="page">
		<!-- Wrapper -->
		<div class="wrapper">
				<!-- Left column/section -->
				<section class="column width6 first">					
					

					
					<div class="clear">&nbsp;</div>
					
					<h3>Data tables</h3>
					
				<input type="text" id="rss_address" class="" value="" name="rss_address" style="width:400px;"/>
				<a href="#" class="btn" id="cm"><span class="icon icon-add">&nbsp;</span>Display</a>
				<input name="add" id="add" type="button" class="btn" value="Add" />	

					<div id="loading_img"></div>
					
					
					<table class="display stylized" id="example">
						<thead>
							<tr>
								<th>Id</th>
								<th>Title</th>
								<th>Links</th>
								<th>CreateTime</th>
								<th>Oper</th>
							</tr>
						</thead>
						<tbody>
							
						</tbody>

				</table>
					
					<div class="clear">&nbsp;</div>
					
				</section>
				<!-- End of Left column/section -->
				
			
				
				
				
		</div>
		<!-- End of Wrapper -->
	</div>
	<!-- End of Page content -->
	
	<%@ include file="footer.jsp"%>

</body>
</html>
